<template>
  <div class="page">
    <h3>基本信息</h3>
    <detail-table :list="baseInfo" :info="form" v-if="form.id"></detail-table>
    <!-- 领取客户后显示联系人详情 -->
    <h3>项目对接信息</h3>
    <el-alert v-if="form.isPublic === '1'" title="已隐藏，请领取客户后查看相关联系方式" type="warning" center :closable="false" />
    <detail-table v-else :list="linkInfo" :info="form"></detail-table>
    <h3>附加信息</h3>
    <detail-table :list="additionalInfo" :info="form"></detail-table>
    <h3>客户所属信息</h3>
    <detail-table :list="belongInfo" :info="form"></detail-table>
    <h3>跟进情况说明</h3>
    <p>{{form.followRemark}}</p>
  </div>
</template>

<script>
import DetailTable from '@/components/zmDetailTable'
import { base, link, additional, belong } from '../components/const'
import {detail} from '@/api/src/customer'

export default {
  name: 'DataInfo',
  components: {
    DetailTable
  },
  props: {
    id: {
      type: String,
      default: ''
    },
    obj: {
      type: Object,
      default: {}
    }
  },
  data () {
    return {
      base,
      link,
      additional,
      belong,
      form: {
        customerName: '',
        customerId: '',
        customerType: '',
        tradeType: '',
        customerStar: '',
        customerSource: '',

        linkMan: '',
        mobile: '',
        fixedMobile: '',
        email: '',

        regionName: '',
        address: '',
        belongCompany: '',
        invoiceCompany: '',
        companyScale: '',
        additionalInformation: '',

        saleMan: '',
        department: '',
        oldSaleMan: '',
        oldDepartment: '',
        createTime: '',
        updateTime: ''
      }
    }
  },
  computed: {
    baseInfo () {
      return this.base(this)
    },
    linkInfo () {
      return this.link(this)
    },
    additionalInfo () {
      return this.additional(this)
    },
    belongInfo () {
      return this.belong(this)
    }
  },
  created () {
    this.getInfo()
  },
  methods: {
    async getInfo () {
      const res = await detail({id: this.id})
      this.$emit('getCustomerName', res.customerName)
      this.$emit('getObj', res)
      this.form = Object.assign({}, this.form, res)
    }
  }
}
</script>

<style scoped lang="scss">
.el-form-item {
  width: 50%;
}
.el-form-item__label {
  background: #ccc !important;
}
</style>
